package com.wg.db.convert;

import cn.hutool.core.util.StrUtil;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

/**
 * @author 少爷123
 */
public class StringSetConvert implements IConvert<Set<String>> {
    @Override
    public Set<String> parseObject(Object obj) {
        if (!(obj instanceof String)) {
            return new HashSet<>();
        }

        String str = (String) obj;
        if (StrUtil.isEmpty(str)) {
            return new HashSet<>();
        }

        Set<String> stringSet = new HashSet<>(32);
        Collections.addAll(stringSet, StrUtil.splitToArray(str, ","));
        return stringSet;
    }
}
